// =======================================================================
// 
//       Filename:  page.hpp
// 
//    Description:  
// 
//        Version:  1.0
//        Created:  27.03.2010 19:13:52
//       Revision:  none
//       Compiler:  g++
// 
//         Author:  Dominik 'domachine' Burgdörfer (-), dominik.burgdoerfer@googlemail.com
//        Company:  -
// 
// =======================================================================


#ifndef  PAGE_INC
#define  PAGE_INC
#include <iostream>
#include <map>
#include <vector>
#include <fstream>
#include <boost/filesystem.hpp>

namespace webplodder {
    // Forward declaration
    namespace navigation {
        class Node;
    }

    namespace page {
        // Forward declaration;
        class Parser;

        /**
         * @brief Represents a *.page file which holds parsed
         * variables and input/output file path.
         */
        class Page : public std::map<std::string,std::string>
        {

            friend class Parser;

            public:
                /**
                 * @brief Constructs page file
                 * @param[in] sourcePath The input file path.
                 * @param[out] outputPath The output file path.
                 */
                Page(const boost::filesystem::path& sourcePath,
                        const boost::filesystem::path& outputPath);

                /**
                 * @brief Writes the content of the page to <i>target</a>
                 */
                void writeContent(std::ostream& target);

                /**
                 * @brief Installs a navigation. Means that it transforms
                 * absolute paths to relative paths.
                 */
                void installNavigation(
                        const std::vector<navigation::Node>& navi);

                /**
                 * @brief Returns the path to the source file.
                 */
                boost::filesystem::path sourcePath() const;

                /**
                 * @brief Returns the path to output file.
                 */
                boost::filesystem::path outputPath() const;

                /**
                 * @brief Returns the installed navigation.
                 * If no navigation was installed. It returns an empty
                 * vector.
                 */
                std::vector<navigation::Node>& navigation();

                /**
                 * @brief Returns the position in the navigation.
                 */
                int pos() const;

                /*
                 * @brief Returns whether the page is in the navigation.
                 */
                bool inMenu() const;

            private:
                boost::filesystem::path m_sourcePath;
                boost::filesystem::path m_outputPath;
                std::vector<navigation::Node> m_navigation;
                int m_pos;
                bool m_inMenu;
        };
    }
}
#endif   // ----- #ifndef PAGE_INC  -----
